package renguanyu.app.codebuilder.view;

import javafx.scene.control.Alert;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class MainView extends BorderPane {

	private Stage primaryStage;
	private MenuBar nav = new MenuBar();
	
	private Menu other = new Menu("代码");
	private MenuItem codeBuilder = new MenuItem("代码生成器");
	private MenuItem pdf = new MenuItem("提取PDF单词");
	
	private Menu help = new Menu("帮助");
	private MenuItem about = new MenuItem("关于Tools");

	public MainView(Stage primaryStage) {
		this.primaryStage = primaryStage;
		initUI();
		initEvent();
	}

	private void initUI() {
		other.getItems().addAll(codeBuilder);
		help.getItems().addAll(about);
		nav.getMenus().addAll(other, help);
		this.setTop(nav);
		this.setId("main");
		this.setPrefHeight(600);
		this.setPrefWidth(800);

	}

	private void initEvent() {
		codeBuilder.setOnAction(event -> this.setCenter(new CodeBuilderView(this)));
		
		about.setOnAction(event -> {
			Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("Tools");
			alert.setHeaderText("作者:任冠宇\nQQ:651231292");
			alert.setContentText("");
			alert.show();
		});
	}

	public Stage getPrimaryStage() {
		return primaryStage;
	}
}
